package cate.common.table.common;

import cate.common.table.ESheet;
import cate.common.util.GameResult;
import easy.java.dev.note.NoteClass;


@NoteClass(value = "功能开启")
public class FuncEnableSheet extends ESheet<FuncEnableRow> {

    @Override
    public String getSheetName() {
        return "功能开启";
    }

    public GameResult<Void> isEnable(int level, int vip, int openday, int worldLevel, int funcId, int adventureNum) {
        GameResult<Void> r = new GameResult<>();
        FuncEnableRow row = this.get(funcId);
        if (row == null) {
            return r.fail("功能不存在");
        }
        if (openday < row.openday) {
            return r.fail("开服天数不足");
        }
        if (level < row.level) {
            return r.fail("主角等级不足");
        }
        if (vip < row.vip) {
            return r.fail("主角vip等级不足");
        }
        if (worldLevel < row.worldLevel) {
            return r.fail("世界等级不足");
        }
        if (adventureNum < row.adventureNum){
            return r.fail("主线通关数不足");
        }
        return r.success();
    }
}
